package com.bao.interkont.mapper;

import com.bao.interkont.pojo.Article;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author bao*
 * @version 1.0
 */
@Mapper
public interface ArticleMapper {
    @Insert("insert into article(uid,title,content,cover) values (#{uid},#{title},#{content},#{cover});")
    public void publishArticle(Article article);

    @Select("select * from article order by watch desc ")
    public List<Article> getArticles();

    @Select("select watch from article where article_id = #{articleId}")
    public Integer getArticle(@Param(value = "articleId") Integer articleId);

    @Select("select * from article where article_id = #{articleId}")
    public Article getArticleByArticleId(@Param(value = "articleId") Integer articleId);

    @Update("update article set watch = watch+1 where article_id = #{articleId} ")
    public void addArticleWatch(@Param(value = "articleId") Integer articleId);
}

